######################################################################
#
#   Header stuff
#
######################################################################
from ship import *
from globalvals import *

######################################################################
# Fake value for testing
shippyA = Alpha([100,100],24,20,8)
shippyB = Bravo([150,150],26,20,8)
shippyC = Charlie([200,200],30,32,8)
shippyD = Delta([250,250],30,32,8)
enemy = Enemy([500,650],30,32,8)
######################################################################
alphas1 = []
alphas2 = []
bravos1 = []
bravos2 = []
deltas1 = []
for i in range(10):
    alphas1.append(Alpha([i*44 + 310, 300],24,20,8));
    alphas2.append(Alpha([i*44 + 310, 260],24,20,8));

for i in range(8):
    bravos1.append(Bravo([i*44 + 354, 220], 26, 20, 8));
#    bravos2.append(Bravo([i*46 + 349, 180], 26, 20, 8));

for i in range(4):
    deltas1.append(Delta([i*88 + 374, 168], 30, 32, 8));

a00 = alphas1[0]
a01 = alphas1[1]
a02 = alphas1[2]
a03 = alphas1[3]
a04 = alphas1[4]
a05 = alphas1[5]
a06 = alphas1[6]
a07 = alphas1[7]
a08 = alphas1[8]
a09 = alphas1[9]

a10 = alphas2[0]
a11 = alphas2[1]
a12 = alphas2[2]
a13 = alphas2[3]
a14 = alphas2[4]
a15 = alphas2[5]
a16 = alphas2[6]
a17 = alphas2[7]
a18 = alphas2[8]
a19 = alphas2[9]

b00 = bravos1[0]
b01 = bravos1[1]
b02 = bravos1[2]
b03 = bravos1[3]
b04 = bravos1[4]
b05 = bravos1[5]
b06 = bravos1[6]
b07 = bravos1[7]

"""b10 = bravos2[0]
b11 = bravos2[1]
b12 = bravos2[2]
b13 = bravos2[3]
b14 = bravos2[4]
b15 = bravos2[5]
b16 = bravos2[6]
b17 = bravos2[7]"""

d0 = deltas1[0]
d1 = deltas1[1]
d2 = deltas1[2]
d3 = deltas1[3]


# Flags for gameplay continuation
readyToPlay = False
gameOver = False

# Launches the main gameplay loop
while not gameOver:
######################################################################
#    Uncomment when ready to add gameplay; just set flags in meantime
#
#    # Remains on intro screen until ready to play or quit, setting the
#    # gameOver flag if appropriate
#    if not readyToPlay:
#        gameOver = checkIntroScreen()
#
#    # Run gameplay for one cycle
#    else:
#        displayGameScreen()
#        updateEnemy()
#        updateFleet()
#        updatePlayer()
#        updateStatus()
#
#        # Checks to see if an end condition is met and sets the readyToPlay
#        # flag accordingly
#        readyToPlay = checkEndCondition()

    SCREEN.fill(Color("black"))
#    shippyA.draw()
#    shippyB.draw()
#    shippyC.draw()
#    shippyD.draw()
    a00.draw()
    a01.draw()
    a02.draw()
    a03.draw()
    a04.draw()
    a05.draw()
    a06.draw()
    a07.draw()
    a08.draw()
    a09.draw()

    a10.draw()
    a11.draw()
    a12.draw()
    a13.draw()
    a14.draw()
    a15.draw()
    a16.draw()
    a17.draw()
    a18.draw()
    a19.draw()

    b00.draw()
    b01.draw()
    b02.draw()
    b03.draw()
    b04.draw()
    b05.draw()
    b06.draw()
    b07.draw()

    """    b10.draw()
    b11.draw()
    b12.draw()
    b13.draw()
    b14.draw()
    b15.draw()
    b16.draw()
    b17.draw()"""
   
    d0.draw()
    d1.draw()
    d2.draw()
    d3.draw()

    enemy.draw()
    pygame.display.flip()

    pygame.event.pump()
    keys = pygame.key.get_pressed()

    if keys[K_LEFT]:
        shippyA.move("left")
        shippyB.move("left")
        shippyC.move("left")
        shippyD.move("left")
        enemy.move("left")
        print ("L")
    if keys[K_RIGHT]:
        shippyA.move("right")
        shippyB.move("right")
        shippyC.move("right")
        shippyD.move("right")
        enemy.move("right")
        print ("R")
    if keys[K_UP]:
        shippyA.move("up")
        shippyB.move("up")
        shippyC.move("up")
        shippyD.move("up")
        print ("U")
    if keys[K_DOWN]:
        shippyA.move("down")
        shippyB.move("down")
        shippyC.move("down")
        shippyD.move("down")
        print ("D")
    if keys[K_SPACE]:
        print ("They would have fired here.")
    if keys[K_LALT] or keys[K_RALT]:
        print ("They would have dived here.")
    if keys[K_ESCAPE] or keys[K_q]:
        gameOver = True
        print ("The end")

    CLOCK.tick(10)
######################################################################    


######################################################################
#               Update functions are listed below                    #
######################################################################    

#def updatePlayer()
